import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import axios from "axios";
import './assets/css/global.css'

Vue.config.productionTip = false

// 设置axios拦截器，确保只有在token存在时才设置header
axios.interceptors.request.use(config => {
  config.headers.token  = window.sessionStorage.getItem('token');
  // if (token) {
  //   config.headers.Authorization = `Bearer ${token}`; // 假设你的后端需要Bearer token
  // }
  return config;
});

// 将axios添加到Vue的原型上
Vue.prototype.$ajax = axios;

new Vue({
  router,
  render: h => h(App)
}).$mount('#app');